// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// A simple "rough and ready" example of localizing a Flutter app.
// Spanish and English (locale language codes 'en' and 'es') are
// supported.

// The pubspec.yaml file must include flutter_localizations in its
// dependencies section. For example:
//
// dependencies:
//   flutter:
//   sdk: flutter
//  flutter_localizations:
//    sdk: flutter

// If you run this app with the device's locale set to anything but
// English or Spanish, the app's locale will be English. If you
// set the device's locale to Spanish, the app's locale will be
// Spanish.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show SynchronousFuture;
import 'package:flutter_localizations/flutter_localizations.dart';

import 'package:acaleph/l10n/AppLocalizations.dart';
import 'package:acaleph/navigation/bottom_navigation.dart';
import 'package:acaleph/common/routes_name.dart';
import 'package:acaleph/pages/login_page.dart';
import 'package:flutter/rendering.dart' show debugPaintSizeEnabled;
import 'package:acaleph/bak/views/firstPage.dart';
import 'package:amap_location/amap_location.dart';
import 'package:flutter_search_bar/flutter_search_bar.dart';

//--------------------国际化 begin-----------------------------
class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
  const AppLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) =>
      ['en', 'vi', 'zh'].contains(locale.languageCode);

  @override
  Future<AppLocalizations> load(Locale locale) {
    // Returning a SynchronousFuture here because an async "load" operation
    // isn't needed to produce an instance of AppLocalizations.
    print(locale.languageCode);
    return SynchronousFuture<AppLocalizations>(AppLocalizations(locale));
  }

  @override
  bool shouldReload(AppLocalizationsDelegate old) => false;
}
//--------------------国际化 end-----------------------------


void main() {
//  debugPaintSizeEnabled=true;

  /*============*/
  //设置ios的key
  /*=============*/
  AMapLocationClient.setApiKey("2aedc57bc4c86019da11086c1c9c5368");
  /*============*/
  //设置ios的key
  /*=============*/
//  runApp(Demo());

  runApp(new MaterialApp(
    // 在窗口管理器中使用此应用程序的单行描述
    onGenerateTitle: (BuildContext context) =>
        AppLocalizations.of(context).title,
    localizationsDelegates: [
      const AppLocalizationsDelegate(),
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
    ],
    theme: new ThemeData(
        inputDecorationTheme:new InputDecorationTheme(
          contentPadding: EdgeInsets.only(left:3.0,top:3.0,right:10.0,bottom:3.0),
          border: const UnderlineInputBorder(),
          filled: true,
        ),
    ),
    supportedLocales: [
      const Locale('en', ''),
      const Locale('vi', ''),
      const Locale('zh', ''),
    ],
    // 程序的默认路由的控件
    home: new BottomMenus(),
//    routes: <String, WidgetBuilder>{
//      '/a': (BuildContext context) => new MyPage(title: AppLocalizations.of(context).pageA),
//      '/b': (BuildContext context) => new MyPage(title: 'B 页面'),
//      '/c': (BuildContext context) => new MyPage(title: 'C 页面')
//    },
    routes: <String, WidgetBuilder>{
      RoutesName.routesHomePage: (BuildContext context) => new BottomMenus(),
      RoutesName.routesRegistPage: (BuildContext context) => new LoginPage(),
      "/location/get":(BuildContext context)=>new LocationGet(),
      "/location/listen":(BuildContext content)=>new LocationListen()
    },
  ));
}
